const state = {
    // 控制侧边栏收起展开
    isCollapse: false,
    // 点击侧边栏对应上边栏展示
    selectMenu: []
  };
  
  const mutations = {
    // 定义点击函数
    collapseMenu(state) {
      state.isCollapse = !state.isCollapse;
    },
    // 上边栏和侧边栏按钮联动效果，增加去重功能，也就是本来上边栏有的标签侧边栏点击不增加
    addMenu(state,payload){
      if(state.selectMenu.findIndex(item => item.path === payload.path) === -1){
          state.selectMenu.push(payload)
      }
    },
    closeMenu(state,payload){
      // 找到点数据索引
      const index = state.selectMenu.findIndex(val => val.name === payload.name)
      //点击到删除就直接从数组中删除
      state.selectMenu.splice(index,1)
    }
  };
  
  export default {
    namespaced: true, // 使用命名空间
    state,
    mutations
  };